#!/bin/bash
#
# batch file to setup
#


################################################################################
#
# echo informations
#

echo
echo "Start ARGOX printer driver installation..."
echo

################################################################################
#
# check and execute uninstall shell script
#

if test -f /usr/share/cups/model/argox/uninstall
then
  echo "Old ARGOX printer driver is found."
  echo "Execute uninstall shell script now..."
  if !(/usr/share/cups/model/argox/uninstall)
  then
    echo "Uninstall old ARGOX printer driver failed."
    echo "Install driver failed."
    echo
    exit 1
  fi
else
  echo "There is no installed ARGOX printer driver."
fi


################################################################################
#
# echo informations
#

echo "Start to copy driver files..."

################################################################################
#
# set own, grp and permissions
#
chown -R root:root ./*
chmod 644  ./ppd/*.ppd
chmod 755  ./uninstall
chmod 755  ./rastertoargox

################################################################################
#
# make install dir
#
mkdir -p /usr/share/cups/model/argox/
chown -R root:root /usr/share/cups/model/argox/
chmod -R 755 /usr/share/cups/model/argox/


################################################################################
#
# copy files
#

cp ./rastertoargox /usr/lib/cups/filter/
cp ./ppd/*.ppd /usr/share/cups/model/argox/
cp ./uninstall /usr/share/cups/model/argox/


echo "Restart spooler - CUPS."
################################################################################
#
# restart 
#
if test -f /etc/init.d/cups
then
  /etc/init.d/cups restart
else
  if test -f /etc/init.d/cupsys
  then
    /etc/init.d/cupsys restart
  fi
fi

################################################################################
#
# echo informations
#
echo
echo "The printer driver is installed completed."
echo "Please select suitable printer driver when installing printer manually."
echo

exit 0

